/****************************************
*  This file created using "Writer B"   *
*      a program written by CTonk       *
*          ctonk87@hotmail.com          *
*     [timestamp 03/04/06  15:34:42]    *
****************************************/

// Object.cpp

#ifndef CPP_OBJECT
#define CPP_OBJECT

#include "Object.h"


// Constructors...
Object::Object()
{
	_vnum = 0;
	_type = 0;
	_level = 0;
	_value = 0;
	_weight = 0;
	_name = new char[30];
	for ( int x=0; x < 30; x++ )
		_name[x] = '\0';
	strcpy( _name, "_name" );
	_keyword = new char[10];
	for ( int x=0; x < 10; x++ )
		_keyword[x] = '\0';
	_short = new char[76];
	for ( int x=0; x < 76; x++ )
		_short[x] = '\0';
	strcpy( _short, "_short" );
	_long = new char[76];
	for ( int x=0; x < 76; x++ )
		_long[x] = '\0';
	strcpy( _long, "_long" );
}

Object::Object( Object& it )
{
	_vnum = it._vnum;
	_type = it._type;
	_level = it._level;
	_value = it._value;
	_weight = it._weight;
	for ( int x=0; x < 30; x++ )
		_name[x] = it._name[x];
	for ( int x=0; x < 10; x++ )
		_keyword[x] = it._keyword[x];
	for ( int x=0; x < 76; x++ )
		_short[x] = it._short[x];
	for ( int x=0; x < 76; x++ )
		_long[x] = it._long[x];
}

Object::~Object()
{
	delete[] _name;
	delete[] _keyword;
	delete[] _short;
	delete[] _long;
}

// Operators...
Object& Object::operator = ( Object& it )
{
	_vnum = it._vnum;
	_type = it._type;
	_level = it._level;
	_value = it._value;
	_weight = it._weight;
	for ( int x=0; x < 30; x++ )
		_name[x] = it._name[x];
	for ( int x=0; x < 10; x++ )
		_keyword[x] = it._keyword[x];
	for ( int x=0; x < 76; x++ )
		_short[x] = it._short[x];
	for ( int x=0; x < 76; x++ )
		_long[x] = it._long[x];
	return *this;
}

// Public accessor methods...
int Object::GetVnum()
{
	return _vnum;
}

void Object::SetVnum( int vnum )
{
	_vnum = vnum;
}

int Object::GetType()
{
	return _type;
}

void Object::SetType( int type )
{
	_type = type;
}

int Object::GetLevel()
{
	return _level;
}

void Object::SetLevel( int level )
{
	_level = level;
}

int Object::GetValue()
{
	return _value;
}

void Object::SetValue( int value )
{
	_value = value;
}

int Object::GetWeight()
{
	return _weight;
}

void Object::SetWeight( int weight )
{
	_weight = weight;
}

char* Object::GetName( void )
{
	return _name;
}

char Object::GetName( int x )
{
	return _name[x];
}

void Object::SetName( char* val )
{
	strcpy( _name, val );
	return;
}

void Object::SetName( const char* val )
{
	strcpy( _name, val );
	return;
}

void Object::SetName( int x, char val )
{
	_name[x] = val;
}

char* Object::GetKeyword( void )
{
	return _keyword;
}

char Object::GetKeyword( int x )
{
	return _keyword[x];
}

void Object::SetKeyword( char* val )
{
	strcpy( _keyword, val );
	return;
}

void Object::SetKeyword( const char* val )
{
	strcpy( _keyword, val );
	return;
}

void Object::SetKeyword( int x, char val )
{
	_keyword[x] = val;
}

char* Object::GetShort( void )
{
	return _short;
}

char Object::GetShort( int x )
{
	return _short[x];
}

void Object::SetShort( char* val )
{
	strcpy( _short, val );
	return;
}

void Object::SetShort( const char* val )
{
	strcpy( _short, val );
	return;
}

void Object::SetShort( int x, char val )
{
	_short[x] = val;
}

char* Object::GetLong( void )
{
	return _long;
}

char Object::GetLong( int x )
{
	return _long[x];
}

void Object::SetLong( char* val )
{
	strcpy( _long, val );
	return;
}

void Object::SetLong( const char* val )
{
	strcpy( _long, val );
	return;
}

void Object::SetLong( int x, char val )
{
	_long[x] = val;
}

// Other methods...
void Object::Display( std::ostream& out ) {
	out << "-Object-";
	out << "\nVnum: " << _vnum;
	out << "\nType: " << _type;
	out << "\nLevel: " << _level;
	out << "\nValue: " << _value;
	out << "\nWeight: " << _weight;
	out << "\nName: " << _name;
	out << "\nKeyword: " << _keyword;
	out << "\nShort: " << _short;
	out << "\nLong: " << _long;
	return;
}

void Object::Display( std::string& out ) {
	out << "-Object-";
	out << "\nVnum: " << _vnum;
	out << "\nType: " << _type;
	out << "\nLevel: " << _level;
	out << "\nValue: " << _value;
	out << "\nWeight: " << _weight;
	out << "\nName: " << _name;
	out << "\nKeyword: " << _keyword;
	out << "\nShort: " << _short;
	out << "\nLong: " << _long;
	return;
}

void Object::Save( std::ofstream& save ) {
	save << _vnum << ' ' << _type << ' ' << _level << ' ' << _value << ' ' << _weight << '\n';
	save << _name << '\n';
	save << _keyword << '\n';
	save << _short << '\n';
	save << _long << '\n';
	return;
}

void Object::Load( std::ifstream& load ) {
	char* temp = new char[1024];

	load >> _vnum >> _type >> _level >> _value >> _weight;
	load >> _name >> _keyword;
	load.get(); load.getline( temp, 1024 ); this->SetShort( temp );
	load.getline( temp, 1024 ); this->SetLong( temp );

	delete [] temp;
	return;
}


#endif // #ifndef CPP_OBJECT
